package aom.ju.ss.view.dialog

import android.app.Activity
import android.view.View
import aom.ju.ss.R
import aom.ju.ss.databinding.DialogSharePromotionBinding
import aom.ju.ss.lpInterface.MyHttpCallBack
import aom.ju.ss.utils.ShareManager
import aom.ju.ss.utils.http.LP_API.share
import aom.ju.ss.utils.http.OKHttpUtils

/**
 * Created by maojunfeng on 2020-01-02.
 * Description:
 */
class SharePromotionDialogLp(
    var ids: Int,
    var act: Activity,
    var onc:View.OnClickListener?
) : BaseDialog(act) {

    init {
        setWidth(-1)
    }

    override fun isBottom(): Boolean {
        return true
    }

    private lateinit var binding: DialogSharePromotionBinding
    override fun init() {
        super.init()
        binding = vBinding as DialogSharePromotionBinding
        binding.llWx.setOnClickListener {
            ShareManager.showShare(activity, "Wechat")
            videosShareNum(ids)
            onc?.onClick(null)
            dis()
        }
        binding.pyq.setOnClickListener {
            ShareManager.showShare(activity, "WechatMoments")
            videosShareNum(ids)
            onc?.onClick(null)
            dis()
        }
        binding.llHaoyou.setOnClickListener {

            dis()
        }
        binding.llShequn.setOnClickListener {
            dis()
        }
        binding.llCancel.setOnClickListener {
            dis()
        }
    }

    private fun videosShareNum(ids: Int) {


        OKHttpUtils(activity)
            .SetApiUrl(share)
            .SetKey("id")
            .SetValue(ids.toString())
            .POST(object :
                MyHttpCallBack {
                override fun ok(jsonString: String?, httpTY: String?) {


                }

                override fun error(e: String?, jsonString: String?, httpTY: String?) {
                }

            })

    }

    override fun getLay(): Int {
        return R.layout.dialog_share_promotion
    }


}